package com.chinaoly.baotou.framework.kafka;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chinaoly.baotou.common.utils.TemplateUtil;
import com.chinaoly.baotou.dao.mapper.PopulationRecordMapper;
import com.chinaoly.baotou.dao.mapper.VehicleRecordMapper;
import com.chinaoly.baotou.model.MessageParams;
import com.chinaoly.baotou.model.TBDev;
import com.chinaoly.baotou.model.es.*;
import com.chinaoly.baotou.model.znbk.AlarmThirdParty;
import com.chinaoly.baotou.model.znbk.PersonDetail;
import com.chinaoly.baotou.service.DevService;
import com.chinaoly.baotou.service.SmsService;
import com.chinaoly.frm.common.utils.CommonUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @description class
 * Create by sunlm
 * on 2022-08-24 10:42
 * Make small but daily progress
 */

@Component
@Slf4j
public class KafkaListeners {

    @KafkaListener(id = "${spring.kafka.kafka-test.group:framework-group}",groupId = "${spring.kafka.kafka-test.group:framework-group}", topics = "${spring.kafka.kafka-test.topic:framework-topic}", containerFactory = "defaultFactory")
    public void kafkaTest(String message, Acknowledgment ack) {
        if(StringUtils.isNotBlank(message)){
            log.info("监听到kafka消息："+message);
        }
        // 手动提交
        ack.acknowledge();
    }
}
